import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import {test} from '../static/js/testAddress.js'
import {product} from '../static/js/productionAddress.js'
// import GoogleCharts from  'vue-google-charts'
// import "./mock/index"
// 引入axios配置
import axios from './plugins/axios'
import './plugins/element'
import {forMateTime} from '../static/js/util.js'
Vue.prototype.$axios = axios
Vue.prototype.forMateTime = forMateTime
Vue.config.productionTip = false
/**钩子函数，当未登录时候不允许在浏览器直接输入路由地址进行跳转**/
axios.defaults.baseUR=process.env.VUE_APP_Axios_baseURL
console.log('当前环境的url是:',process.env.VUE_APP_Axios_baseURL);
if(process.env.NODE_ENV=='production'){
  Vue.prototype.$URL = product
}else{
  Vue.prototype.$URL = test
}
console.log('url',Vue.prototype.$URL)
router.beforeEach((to, from, next) => {
  console.log('钩子函数的路由',to)
  if(to.path === '/apply'||to.query.model=='review'){//注册页面不拦截,作为管理员查看的的时候路由不拦截
    next()
    return
  }
  var token = localStorage.getItem('token')
  if (!token && to.path !== '/login') {
    next('/login');
  } else {
    if (to.meta.title) {
      document.title = to.meta.title
    }
      next();
  }
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
